<template>
  <el-container class="layout-container-demo" style="height: 100%">
    <el-aside :width=elAside.width style="height: 100vh; border-right: #cccdcc solid 0px">
      <Aside :isCollapse="isCollapse" :menu-index="elAside"/>
    </el-aside>

    <el-container style="height: 100%">
      <el-header style="text-align: right; font-size: 12px; border-bottom: #cccdcc solid 2px">
        <Header @doCollapse="doCollapse" :Header="Header"/>
      </el-header>
      <el-main style="height: 100%">
        <Main/>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import Aside from "@/components/Aside.vue";
import Header from "@/components/Header.vue";
import Main from "@/components/Main.vue";

export default {
  data(){
    return{
      // 是处于展开状态
      isCollapse:true,
      // 侧边展开大小
      elAside:{
        widthMin: "3.6vw",
        widthMax: "10vw",
        width: "3.6vw",
        height: "100vh"
      },
      // 头部页面需要传过去的数据
      Header:{
        Operation:{
          style:{
            // 默认展开图标颜色
            color:"#000000"
          }
        }
      }
    }
  },
  components: {
    Aside,Header,Main
  },
  methods:{
    // 处理展开时的操作
    doCollapse(){
      // 取反
      this.isCollapse = !this.isCollapse;
      // 未展开空间和展开空间（侧边导航空间）
      this.elAside.width = this.isCollapse ? this.elAside.widthMin : this.elAside.widthMax;
      // 未展开颜色和展开颜色（图标）
      if (this.isCollapse){
        this.Header.Operation.style.color = "#000000";
      }else{
        this.Header.Operation.style.color = "#d17171";
      }
    }
  }
}

</script>

<style scoped>
.layout-container-demo .el-header {
  position: relative;
  color: var(--el-text-color-primary);
}
.layout-container-demo .el-aside {
  color: var(--el-text-color-primary);
  background: var(--el-color-primary-light-8);
}
.layout-container-demo .el-menu {
  border-right: none;
}
.layout-container-demo .el-main {
  padding: 0;
}
.layout-container-demo .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>
